Skip to content

feat(referencePicker): introduce getReferenceWithPicker()#8532

Open
mejo- wants to merge 2 commits into
mainfrom
feat/reference_picker_return_object
Open

feat(referencePicker): introduce getReferenceWithPicker()#8532
mejo- wants to merge 2 commits into
mainfrom
feat/reference_picker_return_object

Conversation

@mejo-
Copy link
Copy Markdown
Contributor

@mejo- mejo- commented May 13, 2026

Required for Text and Collectives to pass the link title from the picker (e.g. Collectives PagePicker.vue) to the consumer (menubar in Text).

🏁 Checklist

  • ⛑️ Tests are included or are not applicable
  • 📘 Component documentation has been extended, updated or is not applicable
  • 2️⃣ Backport to stable8 for maintained Vue 2 version or not applicable

@mejo- mejo- self-assigned this May 13, 2026
@mejo- mejo- added 3. to review Waiting for reviews feature: functions composables, functions, mixins and other non-components labels May 13, 2026
@mejo-
Copy link
Copy Markdown
Contributor Author

mejo- commented May 13, 2026

/backport to stable8

@mejo- mejo- requested review from Antreesy and susnux May 13, 2026 12:37
@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

❌ Patch coverage is 0% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.31%. Comparing base (1b5d050) to head (9e64b40).
⚠️ Report is 31 commits behind head on main.

Files with missing lines Patch % Lines
src/functions/reference/referencePickerModal.ts 0.00% 15 Missing and 3 partials ⚠️
...chText/NcReferencePicker/NcCustomPickerElement.vue 0.00% 2 Missing and 1 partial ⚠️
...NcRichText/NcReferencePicker/NcReferencePicker.vue 0.00% 2 Missing ⚠️
...ts/NcRichText/NcReferencePicker/NcProviderList.vue 0.00% 1 Missing ⚠️
...ts/NcRichText/NcReferencePicker/NcRawLinkInput.vue 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8532      +/-   ##
==========================================
- Coverage   54.57%   54.31%   -0.26%     
==========================================
  Files         106      106              
  Lines        3443     3461      +18     
  Branches     1004     1009       +5     
==========================================
+ Hits         1879     1880       +1     
- Misses       1323     1336      +13     
- Partials      241      245       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mejo-
Copy link
Copy Markdown
Contributor Author

mejo- commented May 13, 2026

/backport to stable8

@mejo- mejo- requested a review from max-nextcloud May 14, 2026 22:13
@mejo- mejo- force-pushed the feat/reference_picker_return_object branch from 53cfef4 to 367d86b Compare May 18, 2026 08:41
@mejo- mejo- changed the title feat(referencePicker): optionally return object in getLinkWithPicker() feat(referencePicker): introduce getReferenceWithPicker() May 18, 2026
@mejo- mejo- force-pushed the feat/reference_picker_return_object branch 2 times, most recently from 638da91 to 7113c3d Compare May 18, 2026 09:12
Copy link
Copy Markdown
Contributor

@ShGKme ShGKme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand the change correctly, the following components have changed public API:

  • NcReferencePicker
  • NcSearch

Comment thread src/functions/reference/referencePickerModal.ts
Comment thread src/functions/reference/index.ts Outdated
Comment thread src/functions/reference/referencePickerModal.ts
@mejo- mejo- force-pushed the feat/reference_picker_return_object branch 2 times, most recently from 481340b to a4a1f78 Compare May 18, 2026 12:31
mejo- added 2 commits May 18, 2026 14:42
Required for Text and Collectives to pass the link title from the picker
(e.g. Collectives PagePicker.vue) to the consumer (menubar in Text).

Signed-off-by: Jonas <jonas@freesources.org>
- In NcCustomPickerElement we cannot control the submitted type, so let's
  add the type check there as well.
- NcSearch is exported publically and used by apps, so changing its
  return type would introduce a backwards-incompatibility.
- NcProviderList, NcRawLinkInput and NcCustomPickerElement are not
  publically exposed, so we can change the emitted type there.

Signed-off-by: Jonas <jonas@freesources.org>
@mejo- mejo- force-pushed the feat/reference_picker_return_object branch from a4a1f78 to 9e64b40 Compare May 18, 2026 12:42
mejo- added a commit to nextcloud/text that referenced this pull request May 18, 2026
Requires nextcloud-libraries/nextcloud-vue#8532 to have an effect.

Signed-off-by: Jonas <jonas@freesources.org>
@mejo-
Copy link
Copy Markdown
Contributor Author

mejo- commented May 18, 2026

nextcloud/text#8615 and nextcloud/collectives#2522 are the respective PRs in Text and Collectives to use this new feature.

Copy link
Copy Markdown
Contributor

@ShGKme ShGKme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR changes API for custom picker elements - the submit event sends reference as an object instead of a string link.

This change for the custom picker element is not backward compatible. An object cannot be used where the string was expected.

All the components using this result are updated to support both the new object result and the old string link result. All the components are backward compatible and support old custom picker elements.

However, they are not forward compatible. Older nextcloud-vue version will break with new custom picker element.

For example, new Collectives's PagePicker custom picker element emits submit event with { link, title }. Then an old nextcloud-vue's getLinkWithPicker handle it as a string link.

For the smart picker it results in creating '[object Object]' text node.


Proposal 1: instead of changing the existing submit event, add a new event, submit-reference or just pick.

Then custom picker elements can emit both events. Where supported, the new event with extra data will be used, and where not - the old event still works.

Later we can mark the old event as deprecated and remove.

this.$el.dispatchEvent(new CustomEvent('submit', {
	bubbles: true,
	detail: pageLink,
}))
this.$el.dispatchEvent(new CustomEvent('pick', {
	bubbles: true,
	detail: {
		link: pageLink,
		title: page.title,
	},
}))

Proposal 2: submit a string with additional link and title properties. So it is still a string, but we can extract the details

const result = 'https://nextcloud.com'
result.link = 'https://nextcloud.com'
result.title = 'Nextcloud'

Dirty. Hacky. Should work.


Proposal 3: emit an object with toString() method.

const result = {
  link: 'https://nextcloud.com',
  title: 'Nextcloud',
  toString() => 'https://nextcloud.com',
}

It is simpler, but will only work where the value is casted to string. For example, it works for the NcRichText with document.createTextNode(result). But it may not work for all the getLinkWithPicker users...

@ShGKme ShGKme added the enhancement New feature or request label May 26, 2026
@ShGKme ShGKme added this to the 9.9.0 milestone May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews backport-request enhancement New feature or request feature: functions composables, functions, mixins and other non-components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants